<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>MD5</title>
<script type="text/javascript" src="../../javascript/jquery/jquery-1.8.3.js"></script>
<script type="text/javascript" src="../../javascript/cryptojs/rollups/md5.js"></script>
</head>
<body>

	<form id="login" method="post">
		<input id="send" type="button" value="SEND" /> <br />
		<input id="get" type="button" value="GET" /> <br />
	</form>
	<script type="text/javascript">
		$(document).ready(function() {
			var secretmsg = "Longerian";
			$("#send").click(function() {
				var encrypted = CryptoJS.MD5(secretmsg);
				$.ajax({
				    url: '/md5?get=false&send=' + encrypted.toString(),
				    type: 'GET',
				    timeout: 1000,
				    error: function() {
				        alert('Error loading data');
				    },
				    success: function(data) {
						console.log("receive " + data);
				    }
				});
			});
			$("#get").click(function() {
				$.ajax({
				    url: '/md5?get=true',
				    type: 'GET',
				    timeout: 1000,
				    error: function() {
				        alert('Error loading data');
				    },
				    success: function(data) {
						console.log("response " + data);
				    }
				});
			});
		}); 
	</script>
</body>
</html>